/**
 * 初始化详情对话框
 */
var InfMappingInfoDlg = {
    infMappingInfoData : {}
};

/**
 * 清除数据
 */
InfMappingInfoDlg.clearData = function() {
    this.infMappingInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
InfMappingInfoDlg.set = function(key, val) {
	var valSet = (typeof val == "undefined") ? escape($("#" + key).val()) : val;
    this.infMappingInfoData[key] = (valSet == "undefined" || valSet == undefined) ? null : valSet;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
InfMappingInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
InfMappingInfoDlg.close = function() {
    parent.layer.close(window.parent.InfMapping.layerIndex);
}

/**
 * 收集数据
 */
InfMappingInfoDlg.collectData = function() {
    this
    .set('id')
    .set('lsmsName')
    .set('dmzName')
    .set('dmz1')
    .set('dmz2')
    .set('dmz3')
    .set('dmz4')
    .set('dmz5')
    .set('dmz6')
    .set('dmz7')
    .set('lsmsId')
    .set('name')
    .set('dmz8')
    .set('dataType')
    .set('name')
    .set('remark');
}

InfMappingInfoDlg.onChangeFun = function(){
	if($("#dataType").val() == 17){
		$("#dmz2 option:first").prop("selected", 'selected'); 
		$('#dmz2').selectpicker('render');
		$('#portShow').show();
	}else{
		$('#dmz2').val("");
		$('#portShow').hide();
	}
}

/**
 * 提交添加
 */
InfMappingInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/infMapping/add", function(data){
        Feng.success($.i18n.prop("common.add.success"));
        window.parent.InfMapping.table.refresh();
        InfMappingInfoDlg.close();
    },function(data){
        Feng.error($.i18n.prop("common.add.failed"));
    });
    ajax.set(this.infMappingInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
InfMappingInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/infMapping/update", function(data){
        Feng.success($.i18n.prop("common.modify.success"));
        window.parent.InfMapping.table.refresh();
        InfMappingInfoDlg.close();
    },function(data){
        Feng.error($.i18n.prop("common.modify.failed"));
    });
    ajax.set(this.infMappingInfoData);
    ajax.start();
}

$(function() {

});
